package com.xll.controller;


import com.xll.entity.Food;
import com.xll.entity.Hotel;
import com.xll.entity.Order;
import com.xll.entity.TravelBook;
import com.xll.service.FoodService;
import com.xll.service.TravelBookService;
import com.xll.utils.QueryInfo;
import com.xll.utils.Result;
import com.xll.utils.SecurityUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/travelBool")
public class TravelBookController {

    @Autowired
    private TravelBookService travelBookService;
    
    @Autowired
    private FoodService foodService;

    @PostMapping("/findPage")
    public Result findAllCell(@RequestBody QueryInfo queryInfo) {
        return travelBookService.findPage(queryInfo);
    }

    @ApiOperation(value = "添加酒店信息")
    @PostMapping("/insert/{id}")
    public Result insert(@PathVariable Long id) {
        Result byID = foodService.findById(id);
        Food data = (Food) byID.getData();
        TravelBook travelBook = new TravelBook();
        travelBook.setTravelId(data.getId());
        travelBook.setTravelName(data.getTitle());
        travelBook.setUserId(SecurityUtils.getUserId());
        travelBook.setUserName(SecurityUtils.getUsername());
        return travelBookService.insert(travelBook);
    }

}
